package TransactionImplementation

import (
	"SPC/AbstractTransactions"
	"SPC/Database"
	"SPC/Model"
	"SPC/ModelImplementation"
)

type ChangeMemberTransaction struct {
	AbstractTransactions.ChangeAffiliationTransaction
	itsDues float64
	itsMemberId int
}

func NewChangeMemberTransaction(empid int, memberid int, dues float64)*ChangeMemberTransaction{
	n := &ChangeMemberTransaction{
		*AbstractTransactions.NewChangeAffiliationTransaction(empid),
		dues,
		memberid,
	}
	n.ChangeAffiliationTransaction.RecordMembership = n.RecordMembership
	n.ChangeAffiliationTransaction.GetAffiliation = n.GetAffiliation
	return n
}

func (c *ChangeMemberTransaction)RecordMembership(e Model.Employee){
	Database.GetPayrollDatabase().AddUnionMember(c.itsMemberId,e)
}

func (c *ChangeMemberTransaction)GetAffiliation()Model.Affiliation {
	return ModelImplementation.NewUnionAffliliation(c.itsMemberId, c.itsDues)
}